package com.itheima.myreflect2.Student.test1.test2;

import java.util.Random;

/**
 * @program: Myset
 * @description:
 * @author: xuejingjing
 * @create: 2021-06-13 19:06
 **/

//无参数，有返回值的lambda
public class TestLambda2 {
    public static void main(String[] args) {
        useRandomNumHandler(()->{
            //相当于在这里写接口里面的实现方法，按照接口的要求返回
            Random random = new Random();
            int num = random.nextInt(10) + 1;
            return num;
        });

    }
    public static void useRandomNumHandler(RandomNumHandler randomNumHandler){
        int result  = randomNumHandler.getNumber(); //这里开始调用16行
        System.out.println(result);
    }
}

interface RandomNumHandler{
      int  getNumber();
}
